package com.hsgene.product.constants;

/**
 * 商品上下架状态
 *
 * @author wangbing
 * @version 1.0, 2018/10/11
 */
public enum CommodityShelfStatus {

    /**
     * 上架状态
     */
    OFFLINE(0, "已下架"), ONLINE(1, "上架中");

    private final int code;

    private final String desc;

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    CommodityShelfStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static CommodityShelfStatus getEnum(int code) {
        for (CommodityShelfStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }

        throw new IllegalStateException("非法的商品上下架状态code值：" + code);
    }
}
